using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Easy.Authorization.Models.Mapping
{
    public class Aut_NavigationsMap : EntityTypeConfiguration<Aut_Navigations>
    {
        public Aut_NavigationsMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.NavigationKey)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NavigationDispaly)
                .IsRequired();

            this.Property(t => t.NavigationUrl)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("Aut_Navigations");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.NavigationKey).HasColumnName("NavigationKey");
            this.Property(t => t.NavigationDispaly).HasColumnName("NavigationDispaly");
            this.Property(t => t.NavigationUrl).HasColumnName("NavigationUrl");
            this.Property(t => t.ParentId).HasColumnName("ParentId");
            this.Property(t => t.ParentChain).HasColumnName("ParentChain");

            // Relationships
            this.HasOptional(t => t.Aut_Navigations2)
                .WithMany(t => t.Aut_Navigations1)
                .HasForeignKey(d => d.ParentId);

        }
    }
}
